$(document).ready(function() {		
	$("#query").click(function(){
		var UId=$("#UName").val();
		var duId=$("#duName").val();
		var dsId=$("#dsName").val();
		var id=$("#id").val();
		var id=$("#scTime").val();
		
		var timeStart=$("#timeStart").val();
		var timeEnd=$("#timeEnd").val();
		
		$("#personTable").fadeIn("fast");
		$("#loadingPerson").show();
		$.ajax({
  			type: "post",
 			url: "wsq/Sched_find2.action",
 			data:{
			      "UId":UId,"duId":duId,"dsId":dsId,"id":id,
 				  "timeStart":timeStart,
 				  "timeEnd":timeEnd
 				 },
  			success:showData
		});
	});
	
	
	function showData(data){
		$("#listPerson").empty();	
		if(data.pageUtil.list.length==0){
			$("#loadingPerson").hide();
			$("#nonePerson").show();
		}else{
			$("#listPerson").hide();
			$("#nonePerson").hide();
		    $("#loadingPerson").hide();
		    $.each(data.pageUtil.list,function(i,n){
				fillDataToHtml(n.tbDuty.duName, n.tbDetailShift.dsName, n.tbUser.UName,n.tbUser.UName, n.id.scTime);
		  	});
		$("#listPerson").show();
		$("#total").text(data.pageUtil.total);
		$("#page").text(data.pageUtil.page);
		$("#pageCount").text(Math.ceil(data.pageUtil.total/10));
		$("#maxRow").text(data.pageUtil.maxRow);
		}
	}
	
	function fillDataToHtml(duName,dsName,UName,UName,scTime){
		var strHtml="<tr>";		
        strHtml+="<td ><div>"+duName+"</div></td>";
        strHtml+="<td ><div>"+dsName+"</div></td>";
        strHtml+="<td ><div>"+UName+"</div></td>";
        strHtml+="<td ><div>"+UName+"</div></td>";
        strHtml+="<td ><div>"+scTime.replace(/T/," ")+"</div></td>";
        strHtml+="</tr>";
        $("#listPerson").append(strHtml);
	}
});